Skip to main content

ReplacePart

ReplacePart[expr,i->new] yields an expression in which the ith part of expr is replaced by new. 

ReplacePart[expr,{i1->new1,i2->new2,…}] replaces parts at positions in by newn.

ReplacePart[expr,{i,j,…}->new] replaces the part at position {i,j,…}.

ReplacePart[expr,{{i1,j1,…}->new1,…}] replaces parts at positions {in,jn,…} by newn.

ReplacePart[expr,{{i1,j1,…},…}->new] replaces all parts at positions {in,jn,…} by new.

ReplacePart[i->new] represents an operator form of ReplacePart that can be applied to an expression.

Please visit the official Wolfram Language Reference for more details and examples on core symbols.